import MessageQueue from '../plugins/MessageQueue';
import ImageFetch from '../plugins/ImageFetch';

var shopService = {};
// 添加店铺
shopService.addShop = function(call,in_city,position,detailed_address,merchant_name,merchant_type,scope,shopkeeper,phone,tel,user_id,id_card,business_num,uid,lng,lat,shop_introduce,shop_image_one,imgArr,access){
	var params={
		in_city:in_city,
		position:position,
		detailed_address:detailed_address,
		merchant_name:merchant_name,
		merchant_type:merchant_type,
		scope:scope,
		shopkeeper:shopkeeper,
		phone:phone,
		tel:tel,
		user_id:user_id,
		id_card:id_card,
		business_num:business_num,
		uid:uid,
		lng:lng,
		lat:lat,
		shop_introduce:shop_introduce,
		shop_image_one:shop_image_one,
	};
	ImageFetch('shop/add-shop?',params,imgArr,access)
		.then(res=>{
			call(res);
		})
		
}
//商家店铺列表
shopService.userShopLists = function(call,user_id,access){
	var params={
		user_id:user_id,
		access:access,
	};
	MessageQueue('shop/user-shop-lists?',params,function(msg){
		call(msg)
	})
		
}
//根据ID获取店铺详情
shopService.shopIdFind = function(call,s_id,access){
	var params={
		s_id:s_id,
		access:access,
	};
	MessageQueue('shop/shop-id-find?',params,function(msg){
		call(msg)
	})
		
}
//修改店铺信息
shopService.shopIdSave = function(call,params,imgArr,access){
	ImageFetch('shop/shop-id-save?',params,imgArr,access)
		.then(res=>{
			call(res)
		})
}
// 用户店铺审核进度
shopService.userAuditSchedule = function(call,user_id,access){
	var params={
		user_id:user_id,
		access:access,
	};
	MessageQueue('shop/user-audit-schedule?',params,function(msg){
		call(msg)
	})
}
// 首页广告
shopService.bannerLists = function(call,user_id,access){
	var params={
		user_id:user_id,
		access:access,
	};
	MessageQueue('shop/banner-lists?',params,function(msg){
		call(msg)
	})
}
// 查看活动列表
shopService.userActivityLists = function(call,user_id,shop_id,access){
	var params={
		user_id:user_id,
		shop_id:shop_id,
		access:access,
	};
	MessageQueue('shop/user-activity-lists?',params,function(msg){
		call(msg)
	})
}
// 商家发布活动
shopService.addActivity = function(call,title,content,start_time,end_time,person_num,user_id,imgArr,shop_id,access){
	var params={
		title:title,
		content:content,
		start_time:start_time,
		end_time:end_time,
		person_num:person_num,
		user_id:user_id,
		shop_id:shop_id,
	};
	ImageFetch('shop/add-activity?',params,imgArr,access)
		.then(res=>{
			call(res)
		})
}
// 通过id查看活动详情
shopService.activityIdInfo = function(call,id,access){
	var params={
		id:id,
		access:access,
	};
	MessageQueue('shop/activity-id-info?',params,function(msg){
		call(msg)
	})
}
// 商家扫描二维码记录
shopService.shopUserScanCode = function(call,user_id,ewm,access){
	var params={
		user_id:user_id,
		ewm:ewm,
		access:access,
	};
	MessageQueue('shop/shop-user-scan-code?',params,function(msg){
		call(msg)
	},'POST')
}
// 修改活动
shopService.activityIdSave = function(call,params){
	MessageQueue('shop/activity-id-save?',params,function(msg){
		call(msg)
	},'POST')
}
// 文件上传
shopService.upFile = function(call,imgArr,access){
	ImageFetch('shop/up-file?',{},imgArr,access)
		.then(res=>{
			call(res)
		})
}
// 添加活体
shopService.addLiving = function(call,month_birth,cate,num,num_danger,price,get_price,user_id,shop_id,imgArr,access){
	var params={
		month_birth:month_birth,
		cate:cate,
		num:num,
		num_danger:num_danger,
		price:price,
		get_price:get_price,
		user_id:user_id,
		shop_id:shop_id,
	};
	ImageFetch('shop/add-living?',params,imgArr,access)
		.then(res=>{
			call(res)
		})
}
// 发布的活体列表
shopService.myLivingLists = function(call,user_id,shop_id,access){
	var params={
		user_id:user_id,
		shop_id:shop_id,
		access:access,
	};
	MessageQueue('shop/my-living-lists?',params,function(msg){
		call(msg)
	})
}
// 查看活体详情
shopService.myReleaseLivingIdInfo = function(call,sl_id,access){
	var params={
		sl_id:sl_id,
		access:access,
	};
	MessageQueue('shop/my-release-living-id-info?',params,function(msg){
		call(msg)
	})
}
// 修改活体
shopService.myReleaseLivingIdSave = function(call,params,imgArr,access){
	ImageFetch('shop/my-release-living-id-save?',params,imgArr,access)
		.then(res=>{
			call(res)
		})
}
// 删除发布的活体
shopService.myReleaseLivingIdDel = function(call,sl_id,access){
	var params={
		sl_id:sl_id,
		access:access,
	};
	MessageQueue('shop/my-release-living-id-del?',params,function(msg){
		call(msg)
	})
}
// 删除活动
shopService.activityIdDel = function(call,ac_id,access){
	var params={
		ac_id:ac_id,
		access:access,
	};
	MessageQueue('shop/activity-id-del?',params,function(msg){
		call(msg)
	})
}
// 活体列表排序
shopService.myReleaseLivingListsSort = function(call,user_id,type,access){
	var params={
		user_id:user_id,
		type:type,
		access:access,
	};
	MessageQueue('shop/my-release-living-lists-sort?',params,function(msg){
		call(msg)
	})
}
// 代办狗证
shopService.releaseAgency = function(call,technological_process,price,user_id,imgArr,access){
	var params={
		technological_process:technological_process,
		price:price,
		user_id:user_id,
	};
	ImageFetch('shop/release-agency?',params,imgArr,access)
		.then(res=>{
			call(res)
		})
}
// 活体列表排序
shopService.releaseAgencyIdInfo = function(call,id,access){
	var params={
		id:id,
		access:access,
	};
	MessageQueue('shop/release-agency-id-info?',params,function(msg){
		call(msg)
	})
}
// 修改代办狗证
shopService.releaseAgencyIdSave = function(call,params,imgArr,access){
	ImageFetch('shop/release-agency-id-save?',params,imgArr,access)
		.then(res=>{
			call(res)
		})
}
// 添加商品
shopService.addShopGoods = function(call,g_name,g_cate,g_num,g_num_danger,g_price,g_get_price,user_id,shop_id,g_jieshao,g_img_lunbo,g_img_info,imgArr,access){
	var params ={
		g_name:g_name,
		g_cate:g_cate,
		g_num:g_num,
		g_num_danger:g_num_danger,
		g_price:g_price,
		g_get_price:g_get_price,
		user_id:user_id,
		shop_id:shop_id,
		g_jieshao:g_jieshao,
		g_img_lunbo:g_img_lunbo,
		g_img_info:g_img_info,
	}
	ImageFetch('shop/add-shop-goods?',params,imgArr,access)
		.then(res=>{
			call(res)
		})
}
// 商品列表
shopService.myShopGoodsLists = function(call,shop_id,access,type){
	var params={
		shop_id:shop_id,
		access:access,
	};
	if(type){
		params.type = type;
	}
	MessageQueue('shop/my-shop-goods-lists?',params,function(msg){
		call(msg)
	})
}
// 查看商品详情
shopService.shopGoodsIdInfo = function(call,g_id,access){
	var params={
		g_id:g_id,
		access:access,
	};
	MessageQueue('shop/shop-goods-id-info?',params,function(msg){
		call(msg)
	})
}
// 修改商品信息
shopService.myShopGoodsIdSave = function(call,params,imgArr,access){
	ImageFetch('shop/my-shop-goods-id-save?',params,imgArr,access)
		.then(res=>{
			call(res)
		})
}
// 删除商品
shopService.shopGoodsIdDel = function(call,g_id,access){
	var params={
		g_id:g_id,
		access:access,
	};
	MessageQueue('shop/shop-goods-id-del?',params,function(msg){
		call(msg)
	})
}
// 添加银行卡
shopService.userBindBankCard = function(call,card_user,card_num,card_type,opening_bank,telephone,user_id,access){
	var params={
		card_user:card_user,
		card_num:card_num,
		card_type:card_type,
		opening_bank:opening_bank,
		telephone:telephone,
		user_id:user_id,
		access:access,
	};
	MessageQueue('shop/user-bind-bank-card?',params,function(msg){
		call(msg)
	},'POST')
}
// 删除银行卡
shopService.bankInfoDel = function(call,card_id,access){
	var params={
		card_id:card_id,
		access:access,
	};
	MessageQueue('shop/bank-info-del?',params,function(msg){
		call(msg)
	})
}
// 银行卡列表
shopService.userBindBankLists = function(call,user_id,access){
	var params={
		user_id:user_id,
		access:access,
	};
	MessageQueue('shop/user-bind-bank-lists?',params,function(msg){
		call(msg)
	})
}
// 提现申请
// bank_name建设银行(银行卡号)
shopService.subBankMoneyApply = function(call,user_id,bank_name,money,access){
	var params={
		user_id:user_id,
		bank_name:bank_name,
		money:money,
		access:access,
	};
	MessageQueue('shop/sub-bank-money-apply?',params,function(msg){
		call(msg)
	},'POST')
}
// 提现列表
shopService.myApplyLists = function(call,page,user_id,access){
	var params={
		page:page,
		user_id:user_id,
		access:access,
	};
	MessageQueue('shop/my-apply-lists?',params,function(msg){
		call(msg)
	})
}



module.exports = shopService;